package com.gf.pokemon.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gf.pokemon.domain.VoteAdminUser;
import com.gf.pokemon.dto.LoginUser;
import com.gf.pokemon.mapper.VoteAdminUserMapper;
import com.gf.pokemon.platform.exception.PokeErrorCode;
import com.gf.pokemon.platform.exception.PokeException;
import com.gf.pokemon.util.ConvertUtils;

@Service
public class AdminUserService {

	@Resource
	private VoteAdminUserMapper voteAdminUserMapper;
	
	public LoginUser getLoginUser(String name) throws PokeException{
		if(name==null){
			throw new PokeException(PokeErrorCode.INVALID_PARAM,"用户名为空");
		}
		VoteAdminUser user = voteAdminUserMapper.getUserByName(name);
		if(user==null){
			return null;
		}
		LoginUser loginUser = ConvertUtils.convert(user);
		return loginUser;
	}

	public VoteAdminUserMapper getVoteAdminUserMapper() {
		return voteAdminUserMapper;
	}

	public void setVoteAdminUserMapper(VoteAdminUserMapper voteAdminUserMapper) {
		this.voteAdminUserMapper = voteAdminUserMapper;
	}
	
}
